package cn.com.oceansoft.modules.dept.controller;

import cn.com.oceansoft.application.constant.ConfigInfo;
import cn.com.oceansoft.application.common.util.HttpClientUtil;
import cn.com.oceansoft.framework.kits.ApiResult;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created by zhangxh on 2016/11/7.
 */
@Controller
@RequestMapping("depts")
public class DeptController {
    @Resource
    protected ConfigInfo configInfo;
    @RequestMapping(value = "sub",method = RequestMethod.GET)
    @ResponseBody
    public ApiResult approvals(@RequestParam("parent_id") String parent_id, HttpServletRequest request) {
        ApiResult apiResult=null;
            String result= HttpClientUtil.doGet(configInfo.getMsHostUrl()+"depts/"+parent_id+"/sub");
            apiResult = JSONObject.parseObject(result, ApiResult.class);
        return apiResult;
    }

    @RequestMapping(value = "sj", method = RequestMethod.GET)
    @ResponseBody
    public Object findSj(HttpServletRequest request) {
        ApiResult apiResult = null;
            String result = HttpClientUtil.doGet(configInfo.getMsHostUrl() + "depts/sj");
            apiResult = JSONObject.parseObject(result, ApiResult.class);
        return apiResult;
    }
}
